using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace ArchSoft
{
    public partial class ColorCell : UserControl
    {
        [Serializable]
        [ComVisible(true)]
        public delegate void ColorSelectingHandle(object sender, EventArgs e);

        [Serializable]
        [ComVisible(true)]
        public delegate void CellDoubleClickHandle(object sender, EventArgs e);

        public event ColorSelectingHandle ColorSelecting;
        public event CellDoubleClickHandle CellDoubleClick;


        public ColorCell()
        {
            InitializeComponent();
        }

        #region " Property "

        public Color Color
        {
            set { this.button1.BackColor = value; }
            get { return this.button1.BackColor; }
        }

        public Color BackGrdColor
        {
            set { this.label1.BackColor = value; }
            get { return this.label1.BackColor; }
        }

        public ContentAlignment TextAlign
        {
            set { this.label1.TextAlign = value; }
            get { return label1.TextAlign; }
        }

        public string ColorString
        {
            set { this.label1.Text = value; }
            get { return this.label1.Text; }
        }

        private int ColorValue_;
        public int ColorValue
        {
            set { if (value > 0)ColorValue_ = value; }
            get { return ColorValue_; }
        }

        #endregion

        #region " Event "

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ColorSelecting(this, e);
            }
            catch { }
        }

        private void label1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                CellDoubleClick(this, e);
            }
            catch { }
        }

        #endregion        
    }
}
